package com.yjd.pub.order.dao.impl;

import com.yjd.comm.merchant.dto.OrderStatisticDto;
import org.springframework.stereotype.Component;
import com.yjd.comm.base.dao.impl.BaseDaoImpl;
import com.yjd.comm.order.model.OrderModel;
import com.yjd.pub.order.dao.IOrderDao;

import java.util.List;
import java.util.Map;

/**
 * <b>description</b>：订单数据访问层 <br>
 * <b>time</b>：2017-06-27 08:53:50 <br>
 * <b>author</b>： yangchangyan@yijiedai.com
 */
@Component("orderDao")
public class OrderDaoImpl extends BaseDaoImpl implements IOrderDao {

	private static final String SQLMAPNAMESPACE = OrderModel.class.getName();
	private static final String PKNAME = "order_id";

	@Override
	public String getPrimaryKeyName() {
		return PKNAME;
	}

	@Override
	public String getSqlmapNamespace() {
		return SQLMAPNAMESPACE;
	}

	@Override
	public List queryRefundOrder(Map<String, Object> paramMap, boolean write) throws Exception {
		return this.getSqlMap(write).queryForList(this.getStatement("queryRefundOrder"), paramMap);
	}

	@Override
	public List querySettlementOrder(Map<String, Object> paramMap, boolean write) throws Exception {
		return this.getSqlMap(write).queryForList(this.getStatement("querySettlementOrder"), paramMap);
	}

	@Override
	public int updateInvalidOrderStatus(Map<String, Object> parmMap) throws Exception {
		return this.getSqlMap(true).update(this.getStatement("updateInvalidOrderStatus"),parmMap);
	}

	@Override
	public OrderStatisticDto orderStatisticByUser(Long user_id, Map<String, Object> parmMap) throws Exception {
		parmMap.put("user_id", user_id);
		return (OrderStatisticDto)this.getSqlMap(false).queryForObject(this.getStatement("queryOrderStatistic"), parmMap);
	}
}
